<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>超市订单管理系统</title>
		<link type="text/css" rel="stylesheet" href="../css/style.css" />
		<link type="text/css" rel="stylesheet" href="../css/public.css" />
		<style>
			body{
				background-color: white;
			}
		</style>
	</head>
	<body>
		<div class="location">
			<strong>你现在所在的位置是:</strong>
			<span>订单管理页面 &gt;&gt; 订单添加页面</span>
		</div>
		<div class="providerAdd">
			<form id="billForm" name="billForm" method="post">
				<input type="hidden" name="img" id="img" value="">
				<div>
					<label for="billCode">订单封面：</label>
					<img src="../images/default.png" width="50px" name="headImg">
					<input type="file" name="file" id="file" style="border-style: none;box-shadow: 0 0 0;width: 200px" value="选择文件" onchange="upload()" validatestatus="false">
				</div>
				<div>
					<label for="billCode">订单编码：</label>
					<input type="text" name="billCode" class="text" id="billCode" value="" validatestatus="false">
				</div>
				<div>
					<label for="productName">商品名称：</label>
					<input type="text" name="productName" id="productName" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="productUnit">商品单位：</label>
					<input type="text" name="productUnit" id="productUnit" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="productCount">商品数量：</label>
					<input type="text" name="productCount" id="productCount" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label for="totalPrice">总金额：</label>
					<input type="text" name="totalPrice" id="totalPrice" value="">
					<font color="red">*</font>
				</div>
				<div>
					<label>供应商：</label>
					<select name="providerId" id="providerId">
						<option value="0">请选择</option>
						<option value="1">北京三木堂商贸有限公司</option>
						<option value="2">石家庄帅益食品贸易有限公司</option>
					</select>
					<font color="red">*</font>
				</div>
				<div>
					<label>是否付款：</label>
					<input type="radio" name="isPayment" value="1" checked="checked">未付款
					<input type="radio" name="isPayment" value="2">已付款
				</div>
				<div class="providerAddBtn">
					<input type="submit" name="add" id="add" value="保存" onclick="checkForm('add')">
					<input type="button" id="back" name="back" value="返回" onclick="location.href='bill_list.html'">
				</div>
			</form>
		</div>

	<script src="../js/jquery-3.5.1.js"></script>
	<script src="../js/jquery.form.js"></script>
	<script src="../js/common.js"></script>
	<script>
		//加载供应商列表
		loadData_provider();

		$("form").submit(function (){
			$("form").ajaxSubmit({
				url:"../bill/addBill",
				dataType:"json",
				data:{"createdBy":localStorage.id},
				async:false,
				success:function (result){
					if(result.flag){
					    alert(result.msg);
						location.href = "bill_list.html";
					} else {
						alert(result.msg);
					}
				},
				error:function (jqxhr){
					alert("请求出错：" + jqxhr.status);
				}
			});
			//注意，这里的return false必须写。不然	location.href = "bill_list.html"会失效
			return false;
		});

	</script>
	</body>
</html>
